// tuple.go
package main

import (
	"fmt"
)

// type Sequence struct {
// 	Object
// 	data []*Object
// }

// func (self *Sequence) Len() int {
// 	return len(self.data)
// }
// func (self *Sequence) GetValue(index int) *Object {
// 	return self.data[index]
// }

type DrTuple struct {
	DrVarObject
}

func (self *DrTuple) executeMethod(funcName string, prams []IObject) IObject {

	panic("not implemented for the method:" + funcName)

}
func (self *DrTuple) getValue() float64 {
	panic("Only used for simple object such as int and float")
}

func NewTuple(objects []IObject) *DrTuple {
	tuple := new(DrTuple)
	tuple.Elements = objects
	tuple.Type = TypeTuple
	return tuple
}

func (self *DrTuple) getType() DataType {
	return self.Type
}

func (self *DrTuple) GetValue(index int) IObject {
	return self.GetElems()[index]

}
func (self *DrTuple) AsString() string {
	data := self.GetElems()
	s := "("
	for _, v := range data {
		s = s + " " + v.AsString()
	}
	s += ")"
	return s
}
func (self *DrTuple) Print(interp *Interpreter) {
	if interp.hasPrinted(self) {
		fmt.Print("(...)")
	} else {
		interp.PrintSet[self] = 1
		fmt.Print("(")
		data := self.GetElems()
		for _, v := range data {
			v.Print(interp)
			fmt.Print(",")
		}
		fmt.Print(")")

	}
}
func (self *DrTuple) ToList() *DrList {
	list := new(DrList)
	copy(list.Elements, self.GetElems())

	return list
}
func (self *DrTuple) Len() int {
	return len(self.Elements)
}
func (self *DrTuple) Copy() *DrTuple {
	list := new(DrTuple)
	copy(list.Elements, self.GetElems())

	return list
}

func (self *DrTuple) getMembers() map[string]IObject {
	return self.members
}
